﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="MovimentoScarico_CRUD.aspx.cs" Inherits="FimetContoDeposito.Operazioni.MovimentoScarico_CRUD" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <asp:PlaceHolder ID="PlaceHolder1" runat="server"> 
        <%: Scripts.Render("~/bundles/JQuery") %>          
        <%: Scripts.Render("~/bundles/JQueryUI") %>                
        <%: Styles.Render("~/bundles/Formly/css") %>
        <%: Scripts.Render("~/bundles/Formly") %>
    </asp:PlaceHolder>
          
    <script type="text/javascript" lang="javascript" src="../Scripts/Formly/FormlyHelper.js"></script>
    <script type="text/javascript" lang="javascript" src="../Scripts/GrayParrot.Core.js"></script> 
    <script type="text/javascript" lang="javascript" src="../Scripts/GrayParrot.AngularJS.Directives.Fileupload.js"></script> 
    <script type="text/javascript" lang="javascript" src="../Scripts/GrayParrot.AngularJS.Directives.DateTimePicker.js"></script> 
    <script type="text/javascript" lang="javascript" src="../Scripts/GrayParrot.AngularJS.js"></script> 

    <title>Referto Errato</title>

      <style>
          body {
            margin: 20px
          }

          .formly-field {
            margin-bottom: 16px;
          }

          .formly.row{
            display:block;
          }

          .formly-field.section-label {
            margin-bottom: 8px
          }

        .btn-file {
            position: relative;
            overflow: hidden;
        }
        .btn-file input[type=file] {
            position: absolute;
            top: 0;
            right: 0;
            min-width: 100%;
            min-height: 100%;
            font-size: 100px;
            text-align: right;
            filter: alpha(opacity=0);
            opacity: 0;
            outline: none;
            background: white;
            cursor: inherit;
            display: block;
        }
      </style>
</head>

<body ng-app="formlyExample" ng-controller="MainCtrl as vm" id="divFormly" name="divFormly">

    <h1>Movimento SCarico<br /><hr /></h1>
    <table>
        <tr>
            <td style="vertical-align:top">
                <div ng-if="vm.loadingData.$$state.status === 0" style="margin:20px 0;font-size:2em">
                    <strong>Loading...</strong>
                </div>
                <div ng-if="vm.loadingData.$$status.state !== 0">
                    <form ng-submit="vm.onSubmit()" novalidate id="formlyForm">
                        <formly-form model="vm.model" fields="vm.fields" form="vm.form">
                        <button type="sumbit" class="btn btn-primary submit-button" ng-disabled="vm.form.$invalid">Salva</button>
                        </formly-form>
                    </form>
                </div>
            </td>
        </tr>
    </table>


</body>

   <script>

       var idToEdit = GetQueryStringParams("id");

       var settings = new FormlySettings();
       settings.container = '#divFormly';
       settings.callbackSuccess = SuccessCallback;
       settings.onloadCallback = LoadCallback;

       if (idToEdit == undefined) {
           settings.setLoad(settings.createGetConfig('/api/Movimenti/LoadFieldsMovimentoToEdit'));
           settings.setSend(settings.createPostConfig('/api/Movimenti/Add'));
       } else {
           settings.setLoad(settings.createGetConfig('/api/Movimenti/LoadFieldsMovimentoToEdit', { id: idToEdit }));
           settings.setSend(settings.createPostConfig('/api/Movimenti/Edit'));
       }

       FormlyManager(settings);

       //
       function SuccessCallback(response) {

           ShowResponseMessage(response);

           window.parent.CloseDialog();
       }

       function LoadCallback(fields) {
           $(".img-thumbnail").attr("src", fields['FotoArticolo'])
       }
   </script>

</html>

